function Sumrate = Sumrate_MonteCarlo_test(K,L,N,rho,alpha,NUM_timesamples,T2,Hbar2,F,H1,tau)
%UNTITLED5 此处显示有关此函数的摘要
%   此处显示详细说明
for ueIdx = 1:K
    SQR_T2(:,:,ueIdx) =  sqrtm(T2(:,:,ueIdx));
    Hbar(ueIdx,:) =  Hbar2(ueIdx,1:L) * F * H1;
end
x=zeros(K,L,NUM_timesamples);
v=zeros(K,L,NUM_timesamples);
for ueIdx = 1:K
%     x(ueIdx,1:L,:) = [0.0049 - 0.3414i  -0.5786 - 0.1101i   1.1549 - 0.0058i];
%     v(ueIdx,1:L,:) = [-0.3724 - 0.3576i   0.0543 + 0.2418i  -0.9994 - 0.3556i];
    x(ueIdx,1:L,:) = (randn(1,L,NUM_timesamples) + j*randn(1,L,NUM_timesamples))/sqrt(2)/sqrt(L);
    v(ueIdx,1:L,:) = (randn(1,L,NUM_timesamples) + j*randn(1,L,NUM_timesamples))/sqrt(2)/sqrt(L);
    for t = 1:NUM_timesamples
        H(ueIdx,:,t) = Hbar(ueIdx,:) + x(ueIdx,1:L,t) * SQR_T2(:,:,ueIdx) * F * H1;
        Hhat(ueIdx,:,t) = Hbar(ueIdx,:) + (sqrt(1-tau(ueIdx)^2)*x(ueIdx,1:L,t) + tau(ueIdx)*v(ueIdx,1:L,t)) * SQR_T2(:,:,ueIdx) * F * H1;
    end
end
for t = 1:NUM_timesamples
    W(:,:,t) = inv(Hhat(:,:,t)'*Hhat(:,:,t)+alpha*eye(N));
    M_noise(t) = trace(W(:,:,t)*W(:,:,t)*Hhat(:,:,t)'*Hhat(:,:,t))/L;
    
    for k = 1:K
        M_signal(k,t) = rho*(H(k,:,t)*W(:,:,t)*Hhat(k,:,t)')^2;
        M_interferece(k,t) = rho*H(k,:,t)*W(:,:,t)*Hhat([1:k-1 k+1:K],:,t)'*Hhat([1:k-1 k+1:K],:,t)*W(:,:,t)*H(k,:,t)';
        gamma1(k,t) = M_signal(k,t)/(M_interferece(k,t)+M_noise(t));
        rate1(k,t) = log2(abs(1+gamma1(k,t)));
    end
%     M_signal
%     M_interferece
%     M_noise
%     gamma1
end
Sumrate = sum(sum(rate1))/NUM_timesamples; 
end



